﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyClassLibrary;
using MyDB;

namespace MyProgram
{
    public partial class FrmDrugOverMf : FrmBaseModify
    {
        public FrmDrugOverMf()
        {
            InitializeComponent();
        }

        MedicareDataClassesDataContext db = new MedicareDataClassesDataContext();

        internal int drugovIndx;

        private void FrmDrugOverMf_Load(object sender, EventArgs e)
        {
            var q = (from f in db.DrugOverviews
                     where f.藥物ID == drugovIndx
                     select f).First();

            this.label6.Text = q.藥物ID.ToString();
            this.textBox1.Text = q.項目_英文名稱_;
            this.textBox2.Text = q.中文名稱;
            this.textBox3.Text = q.藥品單位含量;
            this.textBox4.Text = q.使用方法;
            this.textBox5.Text = q.使用劑量;
            this.textBox6.Text = q.藥品外觀;
            this.textBox7.Text = q.適應症;
            this.textBox8.Text = q.副作用;
            this.textBox9.Text = q.警語;
            this.textBox10.Text = q.用藥指示;
            this.checkBox1.Checked = (bool)q.特殊與否;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var q = (from f in db.DrugOverviews
                     where f.藥物ID == drugovIndx
                     select f).First();

            q.項目_英文名稱_ = this.textBox1.Text;
            q.中文名稱 = this.textBox2.Text;
            q.藥品單位含量 = this.textBox3.Text;
            q.使用方法 = this.textBox4.Text;
            q.使用劑量 = this.textBox5.Text;
            q.藥品外觀 = this.textBox6.Text;
            q.適應症 = this.textBox7.Text;
            q.副作用 = this.textBox8.Text;
            q.警語 = this.textBox9.Text;
            q.用藥指示 = this.textBox10.Text;
            q.特殊與否 = this.checkBox1.Checked;
            db.SubmitChanges();
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
